home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / parstp25.zip / CALCW.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-14  |  1KB  |  48 lines

  1. (******************************************************************************
  2. *                                    calc                                     *
  3. * HyperAct Inc. CALC - Parser demo program.                                   *
  4. * (c) 1992, 1994 HyperAct Inc, Written By Ron Loewy.                          *
  5. * Version 2.5, Feb. 1994.                                                     *
  6. ******************************************************************************)
  7. program calcW;
  8. {$N+}
  9. uses
  10.    parslib
  11.    ,strings
  12. {$ifdef windows}
  13.    ,wincrt
  14. {$endif}
  15.    ;
  16.  
  17. var
  18.    exitFlag,
  19.    validity : boolean;
  20.    s        : array[0 .. 255] of char;
  21.    result   : double;
  22.  
  23. begin
  24.    writeln('CALC V2.5, HyperAct Inc, Parser demo program');
  25.    writeln;
  26.    writeln('Enter mathematical expression, or QUIT/EXIT to DOS');
  27.    writeln;
  28.    exitFlag := false;
  29.    repeat
  30.       write('CALC> ');
  31.       readln(s);
  32.       strUpper(s);
  33.       if ((strLComp(s, 'QUIT', 4) = 0) or (strLComp(s, 'EXIT', 4) = 0)) then 
  34.          exitFlag := true
  35.       else begin
  36.          result :=  getExpr(s, validity);
  37.          if (not validity) then
  38.             writeln('Error in expression, at position ', trunc(result))
  39.          else
  40.             writeln('RSLT> ', result);
  41.       end; { not a QUIT command }
  42.    until (exitFlag);
  43.    writeln;
  44.    writeln('Thank you for using CALC, HyperAct Inc.');
  45.    writeln;
  46.    { closeWindow; }
  47. end.
  48.